//
//  DataManager.h
//  iFlickr
//
//  Created by 张 霄鹤 on 09-5-31.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//


#import <Foundation/Foundation.h>
#import "XMLRPCResponse.h"

#import "FlickrParser.h"

@interface DataManager : NSObject {
	NSString *userId;
	
	NSString *userName;
	
	NSString *userFullName;
	
	NSString *perms;
	
	/**
	 * API_KEY  32fdd35bca5b784340c0bdf523b9d3cc 
	 */
	NSString *apiKey;
	
	/**
	 * secret key fe8a457a3077648b
	 */
	NSString *secretKey;
	/**
	 * Frob
	 */
	NSString *frob;
	
	NSString *token;
	
	NSString *desc;
	
	FlickrParser *fparser;
}

@property(nonatomic, retain) NSString *token;

@property(nonatomic, retain) NSString *perms;

@property(nonatomic, retain) NSString *userId;

@property(nonatomic, retain) NSString *userName;

@property(nonatomic, retain) NSString *userFullName;

+(id) sharedDataManager;

+(id) alloc;

-(id)initWithApikeyAndSecret:(NSString *)api_key secret:(NSString *)key;

-(void) displayID;

-(NSURL *) getFrobAndAuthURL;

/**
 * 计算 api_sig 同时，会检查 是否添加了 api_key ，如果没有则添加
 */
-(NSString *)genApiSign:(NSString *)method params:(NSDictionary *)paramDict;

-(NSString *)getFrobFromServer;

-(NSString *)getUserToken;

-(BOOL)saveAuthInfo:(NSDictionary *)info;

-(BOOL)loadAuthInfo;

-(BOOL)isAuthorized;

-(void)logout;

#pragma mark -
#pragma mark AppDocumentPath
/**
 Returns the path to the application's documents directory.
 */
- (NSString *)applicationDocumentsDirectory ;


#pragma mark uploadPhoto
-(BOOL)uploadImageToServer:(NSData *)data withParams:(NSDictionary *)params;

-(NSData *)convertMultipart:(NSDictionary *)params withDesc:(NSString *)de;

@end
